﻿using MediatR;
using S.EarTag.API.Mediator.MediatorCommand.EarTagCommand;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;

namespace S.EarTag.API.Mediator.MediatorCommandHandler.EarTagCommandHandler
{
    public class EarTagBatchRemoveCommandHandler : IRequestHandler<EarTagBatchRemoveCommand, bool>
    {
        private readonly IEarTagModelRepository _earTagModelRepository;
        public EarTagBatchRemoveCommandHandler(IEarTagModelRepository earTagModelRepository)
        {
            _earTagModelRepository = earTagModelRepository;
        }
        /// <summary>
        /// 批量删除耳标
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<bool> Handle(EarTagBatchRemoveCommand request, CancellationToken cancellationToken)
        {
            return await _earTagModelRepository.BatchRemoveEarTag(request.ids);
        }
    }
}
